package ua.kpi.javatraining.university;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @author Vasily Yatsenko
 */
public final class Origin {
    private final Date dateOfBirth;
    private final String placeOfBirth;

    public Origin(String placeOfBirth, Date dateOfBirth) {
        this.placeOfBirth = placeOfBirth;
        this.dateOfBirth = dateOfBirth;
    }

    public Date getDateOfBirth() {
        return (Date) dateOfBirth.clone();
    }

    public String getPlaceOfBirth() {
        return placeOfBirth;
    }

    public String toString() {
        StringBuilder builder = new StringBuilder("Born in ");

        builder.append(getPlaceOfBirth());
        builder.append(" ");
        builder.append(DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH).format(getDateOfBirth()));
        return builder.toString();
    }
}
